package afc.dc.project;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
/**
 * This class is the splash screen of the AFCDC app. 
 * It's job is to show the string "TO GOD BE THE GLORY"
 * as soon as the user clicks on the application
 * @author bori
 *
 */
public class Splash_screen extends Activity {

	/**
	 * This method handles the timing of the splash screen
	 * and of course defines the layout
	 */
	protected void onCreate(Bundle bundle){
		super.onCreate(bundle);
		/*The next two lines of code gets rid of the title and makes the app fullscreen. We want to do it right
		 * before we set the content view*/
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
		setContentView(R.layout.splash);
		Thread thread = new Thread(){
			public void run(){
				try {
					sleep(6000);/*sleep for 6 seconds*/
				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				} finally {
					Intent intent = new Intent("church_app.home_screen");/*this is the home screen*/
					startActivity(intent);
				}
			}
		};
		thread.start();/*starts the thread we just created*/
	}

	/**
	 * This method makes sure the splash doesn't come back
	 * if the user presses the back button on their phone.
	 */
	@Override
	protected void onPause() {
		// TODO Auto-generated method stub
		super.onPause();
		finish();/*pretty much kills this activity as soon as the 6 seconds is over*/
	}

}
